<!DOCTYPE html>
<html lang="en">





<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" type="image/png" href="/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="My Personal Website For Blog">
  <meta name="author" content="黄宇辉">
  <meta name="keywords" content="learning note,hexo blog">
  <title>Vue.js的生命周期 - 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/vs2015.min.css" />
  

  


<!-- 主题依赖的图标库，不要自行修改 -->
<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_yg9cfy8wd6.css">

<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">

<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/js/utils.js" ></script>
</head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>ANONYMOUS</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                Home
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                Archives
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                Tags
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                About
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="view intro-2" id="background" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2019-07-20 21:56">
      July 20, 2019 pm
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.4k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      16
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <div class="post-content mx-auto" id="post">
            
            <article class="markdown-body">
              <h2 id="学习笔记-详解Vue-js的生命周期"><a href="#学习笔记-详解Vue-js的生命周期" class="headerlink" title="学习笔记 : 详解Vue.js的生命周期"></a>学习笔记 : 详解Vue.js的生命周期</h2><h3 id="Vue实例的生命周期函数"><a href="#Vue实例的生命周期函数" class="headerlink" title="Vue实例的生命周期函数"></a>Vue实例的生命周期函数</h3><p><em>从Vue实例创建,运行,到销毁期间,总是伴随着各种各样的事件,这些事件统称为生命周期,至于生命周期钩子只不过是生命周期事件的别名而已. 其生命周期图如下所示 :</em></p>
<p><img src="/2019/07/20/Vue-js%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/Vue-lifecycle.png" srcset="/img/loading.gif" alt></p>
<h4 id="初始阶段"><a href="#初始阶段" class="headerlink" title="初始阶段"></a>初始阶段</h4><table>
<thead>
<tr>
<th align="center">钩子函数</th>
<th align="center">描述</th>
<th align="center">数据</th>
<th align="center">真实DOM</th>
<th align="center">项目中的应用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">beforeCreate</td>
<td align="center">表示组件创建前的准备工作,为事件的发布订阅和生命周期的开始做初始化</td>
<td align="center">无</td>
<td align="center">无</td>
<td align="center">项目中一般不使用</td>
</tr>
<tr>
<td align="center">created</td>
<td align="center">表示组件创建结束</td>
<td align="center">有</td>
<td align="center">无</td>
<td align="center">异步数据请求,然后可以进行一次默认数据的修改</td>
</tr>
<tr>
<td align="center">beforeMount</td>
<td align="center">表示组件装载前的准备工作(VDOM)</td>
<td align="center">有</td>
<td align="center">无</td>
<td align="center">数据请求,它也可以进行一次数据修改</td>
</tr>
<tr>
<td align="center">mounted</td>
<td align="center">组件挂载结束,真实DOM渲染完成</td>
<td align="center">有</td>
<td align="center">有</td>
<td align="center">DOM操作,第三方库的实例化</td>
</tr>
</tbody></table>
<ul>
<li><em><code>beforeCreate</code> : 在实例初始化之后,数据观测(data observer)和event/watcher事件配置之前被调用</em></li>
<li><em><code>created</code> : 实例已经创建完成之后被调用. 在这一步,实例已完成以下的配置 : 数据观测(data observer)属性初始化和方法的运算,watch/event事件回调. 然而挂载阶段还没开始,<code>$el</code>属性目前不可见</em></li>
<li><em><code>beforeMount</code> : 在挂载开始之前被调用,相关的render函数首次被调用</em></li>
<li><em><code>mounted</code> : <code>el</code>被新创建的<code>vm.$el</code>替换，并挂载到实例上去之后调用该钩子. 如果root实例挂载了一个文档内元素,当mounted被调用时vm.$el也在文档内</em></li>
</ul>
<h4 id="运行阶段"><a href="#运行阶段" class="headerlink" title="运行阶段"></a>运行阶段</h4><table>
<thead>
<tr>
<th align="center">钩子函数</th>
<th align="center">描述</th>
<th align="center">数据</th>
<th align="center">真实DOM</th>
<th align="center">项目中的应用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">beforeUpdate</td>
<td align="center">数据更新前的准备工作,数据修改才会执行</td>
<td align="center">有(修改后的数据)</td>
<td align="center">有</td>
<td align="center">生成新的VDOM,然后通过diff算法进行两次VDOM对比,没有太多的操作意义</td>
</tr>
<tr>
<td align="center">updated</td>
<td align="center">数据更新结束,通过render函数渲染真实DOM</td>
<td align="center">有</td>
<td align="center">有(重新渲染后的真实DOM)</td>
<td align="center">可以进行异步数据请求得到的DOM渲染的第三方库实例化</td>
</tr>
</tbody></table>
<ul>
<li><em><code>beforeUpdate</code> : 数据更新时调用,发生在虚拟DOM重新渲染和打补丁之前. 你可以在这个钩子中进一步地更改状态,这不会触发附加的重渲染过程</em></li>
<li><em><code>updated</code> : 由于数据更改导致的虚拟DOM重新渲染和打补丁,在这之后会调用该钩子. 当这个钩子被调用时,组件DOM已经更新,所以你现在可以执行依赖于DOM的操作</em></li>
</ul>
<h4 id="销毁阶段"><a href="#销毁阶段" class="headerlink" title="销毁阶段"></a>销毁阶段</h4><table>
<thead>
<tr>
<th align="center">钩子函数</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">beforeDestroy</td>
<td align="center">组件即将销毁,准备调用<code>$destroy()</code>方法</td>
</tr>
<tr>
<td align="center">destroyed</td>
<td align="center">组件销毁结束</td>
</tr>
</tbody></table>
<ul>
<li><em><code>beforeDestroy</code> : 实例销毁之前调用. 在这一步,实例仍然完全可用</em></li>
<li><em><code>destroyed</code> : Vue实例销毁后调用. 调用后,Vue实例指示的所有东西都会解绑定,所有的事件监听器会被移除,所有的子实例也会被销毁</em></li>
</ul>
<h3 id="生命周期函数程序示例"><a href="#生命周期函数程序示例" class="headerlink" title="生命周期函数程序示例"></a>生命周期函数程序示例</h3><p><em>可通过下面这个简单实例来观察这些生命周期函数执行的时机哟 ~</em></p>
<div class="hljs"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE html&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
	<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
		<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"utf-8"</span>&gt;</span>
		<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"resources/vue.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
		<span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>the life cycle of Vue<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
	<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
	<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
		<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"app"</span>&gt;</span>
			<span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>&#123;&#123;title&#125;&#125;<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
			<span class="hljs-tag">&lt;<span class="hljs-name">button</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">"randomTitle()"</span>&gt;</span>Change title<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
			<span class="hljs-tag">&lt;<span class="hljs-name">button</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">"destoryVm()"</span>&gt;</span>destory VM<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
		<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
		<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
			<span class="hljs-keyword">var</span> vm = <span class="hljs-keyword">new</span> Vue(&#123;
				<span class="hljs-attr">el</span>: <span class="hljs-string">'#app'</span>,
				data() &#123;
					<span class="hljs-keyword">return</span> &#123;
						<span class="hljs-attr">title</span>: <span class="hljs-string">'Hi Vue !'</span>
					&#125;
				&#125;,
				<span class="hljs-comment">//methods将被混入到Vue实例中.可以直接通过VM实例访问这些方法,或者在指令表达式中使用.</span>
				<span class="hljs-comment">//方法中的this自动绑定为Vue实例.</span>
				<span class="hljs-attr">methods</span>: &#123;
					<span class="hljs-attr">randomTitle</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>&#123;
						<span class="hljs-comment">//floor:returns the largest integer less than or equal to a number. </span>
						<span class="hljs-keyword">this</span>.title = <span class="hljs-string">'Hi '</span> + [<span class="hljs-string">'HTML'</span>, <span class="hljs-string">'CSS'</span>, <span class="hljs-string">'JS'</span>][<span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">2.99</span>)]
					&#125;,
					<span class="hljs-attr">destoryVm</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>&#123;
						<span class="hljs-keyword">this</span>.$destroy()
					&#125;
				&#125;,
				<span class="hljs-comment">//实例初始化后,数据观测和事件绑定之前</span>
				beforeCreate() &#123;
					<span class="hljs-comment">//注:此时data和methods还未被初始化哟</span>
					<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'before create'</span>)
				&#125;,
				<span class="hljs-comment">//实例初始化完成,挂载尚未开始时 </span>
				created() &#123;
					<span class="hljs-comment">//注:此时data与methods已被初始化了哟</span>
					<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'created'</span>)
				&#125;,
				<span class="hljs-comment">//挂载之前,render函数首先被调用时</span>
				beforeMount() &#123;
					<span class="hljs-comment">//注:此时模板已在内存中编译完成,但尚未把模板渲染到页面中</span>
					<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'before mount'</span>)
				&#125;,
				<span class="hljs-comment">//在实例挂载到DOM节点之后</span>
				mounted() &#123;
					<span class="hljs-comment">//注:此时内存中的模板已真实挂载到页面中,继而完成页面的渲染</span>
					<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'mounted'</span>)
				&#125;,
				<span class="hljs-comment">//数据更新时,在虚拟DOM状态变化之前</span>
				beforeUpdate() &#123;
					<span class="hljs-comment">//注:数据被修改时则触发该事件,但此时页面上的数据并未更新哟</span>
					<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'before update'</span>)
				&#125;,
				<span class="hljs-comment">//虚拟DOM被重新渲染之后</span>
				updated() &#123;
					<span class="hljs-comment">//注:此时页面中的数据已经与data保持同步了哟</span>
					<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'updated'</span>)
				&#125;,
				<span class="hljs-comment">//实例销毁之前,此时实例依然可用</span>
				beforeDestroy() &#123;
					<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'before destory'</span>)
				&#125;,
				<span class="hljs-comment">//实例销毁后,此时Vue实例及其子实例将完全解绑</span>
				destroyed() &#123;
					<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'destoryed'</span>)
				&#125;
			&#125;);
		</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
	<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span></code></pre></div>
<ol>
<li><em>刚打开页面,既Vue示例刚被创建并挂载到DOM上时,调用的钩子函数如下图所示 :</em></li>
</ol>
<p><img src="/2019/07/20/Vue-js%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/Vue-js%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%5Cvue-lifecycle-created+mounted.PNG" srcset="/img/loading.gif" alt></p>
<ol start="2">
<li><em>点击<code>change title</code>按钮来改变标题数据,继而会触发视图更新,调用的钩子函数如下图所示 :</em></li>
</ol>
<p><img src="/2019/07/20/Vue-js%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/Vue-js%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%5Cvue-lifecycle-updated.PNG" srcset="/img/loading.gif" alt></p>
<ol start="3">
<li><em>点击<code>destroy VM</code>按钮来销毁Vue实例,调用的钩子函数如下图所示 :</em></li>
</ol>
<p><img src="/2019/07/20/Vue-js%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/Vue-js%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%5Cvue-lifecycle-destroyed.PNG" srcset="/img/loading.gif" alt></p>
<ol start="4">
<li><em>之后,尝试多次点击<code>chang title</code>按钮,发现视图不再响应数据的变化,继而证明此时节点上绑定的Vue实例已被销毁 !</em></li>
</ol>

            </article>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/Vue/">Vue</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" target="_blank" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <div class="post-prev col-6">
                    
                    
                      <a href="/2019/07/21/Vue-js%E7%9A%84%E8%AF%AD%E6%B3%95/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Vue.js的语法</span>
                        <span class="visible-mobile">Previous</span>
                      </a>
                    
                  </div>
                  <div class="post-next col-6">
                    
                    
                      <a href="/2019/07/19/Hi-Vue/">
                        <span class="hidden-mobile">Hi Vue ~</span>
                        <span class="visible-mobile">Next</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </div>
                </div>
              
            </div>

            
          </div>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;TOC</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Search</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">keyword</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


    

    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: 'article.markdown-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "Vue.js的生命周期&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>







  
  
    <script>
      !function (e, t, a) {
        function r() {
          for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
          requestAnimationFrame(r)
        }

        function n() {
          var t = "function" == typeof e.onclick && e.onclick;
          e.onclick = function (e) {
            t && t(), o(e)
          }
        }

        function o(e) {
          var a = t.createElement("div");
          a.className = "heart", s.push({
            el: a,
            x: e.clientX - 5,
            y: e.clientY - 5,
            scale: 1,
            alpha: 1,
            color: c()
          }), t.body.appendChild(a)
        }

        function i(e) {
          var a = t.createElement("style");
          a.type = "text/css";
          try {
            a.appendChild(t.createTextNode(e))
          } catch (t) {
            a.styleSheet.cssText = e
          }
          t.getElementsByTagName("head")[0].appendChild(a)
        }

        function c() {
          return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
        }

        var s = [];
        e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
          setTimeout(e, 1e3 / 60)
        }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
      }(window, document);
    </script>
  














</body>
</html>
